﻿@{
    ViewBag.Title = "Common Command";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<ol class="breadcrumb">
    <li><a href="/Home/Home">Home</a></li>
    <li><a href="/Common/CommonIntoduction"> Sanelib Common</a></li>
    <li class="active">Events</li>
</ol>
<div id="introduction">
    <h1 class="text-left">Events</h1>
    <p>Event is indicating that something has happened, such as a keystroke or mouse click .The Main Difference of Command and Event is Command Processing Require Client while In Event is not Required It is automatically raise when something has happened.
    <br/>Event have set Some Values Of Getter and Setter Methods When it is raise.</p>
    <p>For Example UserCompletedLogInEvent .</p>
    <pre><code>public class UserCompletedLogIn : IEvent<br />{<br />public Guid UserId { get; set; }<br />public UserCompletedLogIn(Guid userId)<br />{<br />UserId = userId;<br />}<br />}
    </code></pre>
    <p>In this Example When User Login and User Successfully Completed Login this Event is raise and set the Login UserId Value this User is Login.This Event is raise with EventCoordinator.Raise(new UserCompletedLogIn(user.Id)); in UserSession.cs file.This Event is handled by IEventHandler.</p>
   <pre><code>EventCoordinator.Raise(new UserCompletedLogIn(user.Id));</code></pre>
   <p>For Another Example PasswordRecoveredEvent </p>
    <pre><code>public class PasswordRecovered : IEvent<br />{<br />public string UserNameOrEmailAddress { get; set; }<br />public string Url { get; set; }<br />public string Token { get; set; }<br />public PasswordRecovered(string userNameOrEmailAddress, string url)<br />{<br />UserNameOrEmailAddress = userNameOrEmailAddress;<br />Url = url;<br />}<br />}</code></pre>
    <p>In This example PassWordRecovered When the Event is Raise with EventCoordinator.Raise(new PasswordRecovered()) in AccountRecoveryController.cs that is RecoveredPassword After this event is Handled By IEventHandler.</p>
    <p>Events have the EventCoordinator that contain IEvent Interface.</p>
    <pre><code>public interface IEvent { }</code></pre>
    <p>CommandCoordinator that also Contain IEventHandler Interface.</p>
    <pre><code>public interface IEventHandler &lt;TEvent&gt; where TEvent : IEvent<br />{<br />void Handle(TEvent evt);<br />}</code></pre>
    <p>IEventHandler is Generic interface that contains Handle Method that handle the event.</p>In this Events also Include MemberRegistrationEvent, UserCompletedLogout, UserCredentialMismatch
</div>
